// 小数相加
function numAdd(n1, n2) {
    let r1 = 0, r2 = 0, m;
    r1 = n1.toString().split(".")[1].length;
    r2 = n2.toString().split(".")[1].length;
    m = Math.pow(10, Math.max(r1, r2))
    return (n1 * m + n2 * m) / m
}

// 大数相加
function bigNumAdd(n1, n2) {
    let maxLength = Math.max(n1.length, n2.length);
    let num1 = n1.padStart(maxLength, 0);
    let num2 = n2.padStart(maxLength, 0);
    let t = 0;
    let f = 0;
    let sum = ""
    for (let i = maxLength - 1; i >= 0; i--) {
        t = parseInt(num1[i]) + parseInt(num2[1]) + f
        f = Math.floor(t / 10)
        sum = t % 10 + sum
    }
    if (f == 1) {
        sum = "1" + sum
    }
    return sum;
}

// 大数相乘
function bigNumMultip(n1, n2) {
    if (isNaN(n1) || isNaN(n2)) return "";
    let len1 = n1.length;
    let len2 = n2.length;
    let pos = []

    for (let j = len2 - 1; j >= 0; j--) {
        for (let i = len1 - 1; i >= 0; i--) {
            let index1 = i + j;
            let index2 = i + j + 1;
            let mul = n1[i] * n2[j] + (pos[index2] || 0)
            pos[index1] = Math.floor(mul / 10) + (pos[index1] || 0)
            pos[index2] = mul % 10
        }
    }

    let result = pos.join("").replace(/^0+/,"")
    return result || "0"
}